/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * mainFrame.java
 *
 * Created on Apr 25, 2011, 12:23:47 AM
 */

package DesktopGUIpackage;

import Controller.DesktopController;
import Controller.DesktopControllerHelper;
import javax.swing.JPanel;

/**
 *
 * @author Spence
 */
public class mainFrame extends javax.swing.JPanel {

    private DesktopControllerHelper controller;
   // private DesktopControllerHelper desktopControllerHelper;
    private Desktop_MainIn mainIn;
    private Desktop_MainOut mainOut;
    private boolean loggedIn;
    /** Creates new form mainFrame */
    public mainFrame(DesktopControllerHelper control) {
        initComponents();
        controller = control;
        customInit();
    }

    private void customInit(){
        Desktop_Welcome welcome = new Desktop_Welcome(controller);
        welcome.setBounds(0,0,1042, 750);
        this.add(welcome);
        loggedIn = false;
    }

    public void mainInScreen(){
        mainIn = new Desktop_MainIn(controller);
        this.removeAll();
        mainIn.setBounds(0,0,1042, 750);
        this.add(mainIn);
        this.validate();
        this.repaint();
        loggedIn = true;
    }

    public void mainOutScreen(){
        mainOut = new Desktop_MainOut(controller);
        this.removeAll();
        mainOut.setBounds(0,0,1042, 750);
        this.add(mainOut);
        this.validate();
        this.repaint();
        loggedIn = false;
    }

    public void databaseDownScreen(){
        DatabaseDown down = new DatabaseDown(controller);
        down.setBounds(0, 0, 1042, 750);
        this.removeAll();
        down.setBounds(0,0,1042, 750);
        this.add(down);
        this.validate();
        this.repaint();
        loggedIn = false;
    }

    public void changeScreen(JPanel panel){
        if (loggedIn){
            mainIn.changeScreen(panel);
        }
        else{
            mainOut.changeScreen(panel);
        }

    }

    public void setTotals(){
        if (loggedIn){
            mainIn.setTotals();
        }
        else{
            mainOut.setTotals();
        }
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 1042, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 750, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
